package com.content.view.Component.CButton
{
	import com.content.view.Component.Button.TextButtonICO;
	import com.library.core.IDisposable;
	import com.library.core.UIObject;
	import com.library.utils.Geometry;
	
	import flash.display.DisplayObject;
	import flash.display.Shape;
	import flash.events.MouseEvent;
	import flash.geom.ColorTransform;
	
	public class CButtonLevel2 extends UIObject implements IDisposable
	{
		
		private var _vo:Level2VO;
		private var _bg:Shape;
		private var _btn:TextButtonICO;
		
		private var _overColor:uint = 0xcdcdcd;
		private var _outColor:uint = 0x0d0d0d;
		private var _width:int;
		private var _height:int;
		
		public function CButtonLevel2(obj:DisplayObject, vo:Level2VO, width:int, height:int)
		{
			super();
			this.mouseChildren = false;
			this.buttonMode = true;
			
			_vo = vo;
			_width = width;
			_height = height;
			
			_bg = new Shape();
			addChild(_bg);
			
			_btn = new TextButtonICO(obj, vo.Text);
			addChild(_btn);
			
			_btn.x = int((width - _btn.width)/2);
			_btn.y = int((height - _btn.height)/2);
			
			_bg.graphics.clear();
			_bg.graphics.lineStyle(1, 0x555555, 1);
			_bg.graphics.beginFill(_outColor);
			_bg.graphics.drawRoundRect(0, 0, width, height, 5, 5);
			
			this.addEventListener(MouseEvent.MOUSE_OVER, OnOver);
			this.addEventListener(MouseEvent.MOUSE_OUT, OnOut);
			
		}
		
		/* Event Handler
		 * -------------------------------------------------------------*/
		private function OnOver(evt:MouseEvent):void{
			_bg.graphics.clear();
			_bg.graphics.beginFill(_overColor);
			_bg.graphics.drawRoundRect(0, 0, _width, _height, 5, 5);
			
			var ct:ColorTransform = new ColorTransform(205, 205, 205);
			_btn.transform.colorTransform = ct;
		}
		private function OnOut(evt:MouseEvent):void{
			_bg.graphics.clear();
			_bg.graphics.beginFill(_outColor);
			_bg.graphics.drawRoundRect(0, 0, _width, _height, 5, 5);
			
			var ct:ColorTransform = new ColorTransform(13,13,13);
			_btn.transform.colorTransform = ct;
		}
		
		public function get MPID():String{
			return _vo.MPID;
		}
		
		public function get Order():int{
			return _vo.Order;
		}
		
		public function Dispose():void{
			this.removeEventListener(MouseEvent.MOUSE_OVER, OnOver);
			this.removeEventListener(MouseEvent.MOUSE_OUT, OnOut);
			_btn.Dispose();
		}
	}
}